In [1]:
x = 5
In [2]:
print x
In [3]:
print type(x)
In [240]:
a = 4 + 5
b = 4 * 5
c = 5 / 4
print a, b, c
In [241]:
print -5 / 4
In [242]:
print -(5 / 4)
In [243]:
x = 5 * 1000000 * 1000000 * 1000000 * 1000000 + 1
print x
print type(x)
In [244]:
y = 5
print type(y)
y = x
print type(y)
In [245]:
y = 5.7
In [246]:
print y
print type(y)
In [247]:
a = 4.2 + 5.1
b = 4.2 * 5.1
c = 5.0 / 4.0
print a, b, c
In [248]:
a = 5
b = 4
print float(a) / float(b)
In [249]:
print 5.0 / 4
print 5 / 4.0
In [250]:
print float(a) / b
In [251]:
a = True
b = False
print a
print type(a)
print b
print type(b)
In [252]:
print a + b
print a + a
print b + b
In [253]:
print int(a), int(b)
In [254]:
print True and False
print True and True
print False and False
In [255]:
print True or False
print True or True
print False or False
In [256]:
z = None
print z
print type(z)
In [257]:
print int(z)
In [258]:
x = "abc"
print x
print type(x)
In [259]:
a = 'Ivan'
b = "Ivanov"
s = a + " " + b
print s
In [260]:
print a.upper()
print a.lower()
In [261]:
print len(a)
In [262]:
print bool(a)
print bool("")
In [263]:
print int(a)
In [264]:
print a
print a[0]
print a[1]
print a[0:3]
In [265]:
print a[0:4:2]
In [266]:
x = u"abc"
print x
print type(x)
In [267]:
x = u'Элеонора Михайловна'
print x, type(x)
y = x.encode('utf-8')
print y, type(y)
z = y.decode('utf-8')
print z, type(z)
q = y.decode('cp1251')
print q, type(q)
In [248]:
1
Out[248]:
In [263]:
x = u'Элеонора Михайловна'
print x, type(x)
y = x.encode('utf-8')
print y, type(y)
z = y.decode('utf-8')
print z, type(z)
q = y.decode('cp1251')
print q, type(q)
In [268]:
print str(x)
In [269]:
print y[1:]
print len(y), type(y)
print len(x), type(x)
In [270]:
y = u'Иван Иванович'.encode('utf-8')
print y.decode('utf-8')
In [271]:
print y.decode('cp1251')
In [273]:
splitted_line = "Ivanov Ivan Ivanovich".split(' ')
print splitted_line
In [274]:
print type(splitted_line)
In [275]:
print "Иванов Иван Иванович".split(" ")
In [277]:
print "\x98"
In [278]:
print u"Иванов Иван Иванович".split(" ")
In [279]:
saled_goods_count = [33450, 34010, 33990, 33200]
print saled_goods_count
print type(saled_goods_count)
In [280]:
income = [u'Высокий', u'Средний', u'Высокий']
names = [u'Элеонора Михайловна', u'Иван Иванович', u'Михаил Абрамович']
print income
print names
In [282]:
print "---".join(income)
In [283]:
features = ['Ivan Ivanovich', 'Medium', 500000, 12, True]
print features
In [284]:
print features[0]
print features[1]
print features[3]
In [285]:
print features[0:5]
In [286]:
print features[:5]
In [287]:
print features[1:]
In [288]:
print features[2:5]
In [289]:
print features[:-1]
In [290]:
features.append('One more element in list')
print features
In [291]:
del features[-2]
In [292]:
print features
In [293]:
features_tuple = ('Ivan Ivanovich', 'Medium', 500000, 12, True)
print type(features_tuple)
In [294]:
features_tuple[2:5]
Out[294]:
In [295]:
features_tuple.append('one more element')
In [296]:
names = {'Ivan', 'Petr', 'Konstantin'}
In [297]:
print type(names)
In [298]:
print 'Ivan' in names
In [299]:
print 'Mikhail' in names
In [300]:
names.add('Mikhail')
print names
In [301]:
names.add('Mikhail')
print names
In [302]:
names.remove('Mikhail')
print names
In [303]:
names.add(['Vladimir', 'Vladimirovich'])
In [304]:
names.add(('Vladimir', 'Vladimirovich'))
print names
In [305]:
a = range(10000)
b = range(10000)
b = set(b)
In [306]:
print a[:5]
print a[-5:]
In [307]:
%%time
print 9999 in a
In [308]:
%%time
print 9999 in b
In [309]:
words_frequencies = dict()
words_frequencies['I'] = 1
words_frequencies['am'] = 1
words_frequencies['I'] += 1
print words_frequencies
In [310]:
print words_frequencies['I']
In [311]:
words_frequencies = {'I': 2, 'am': 1}
print words_frequencies
In [312]:
yet_another_dict = {'abc': 3.4, 5: 7.8, u'123': None}
print yet_another_dict
In [313]:
yet_another_dict[(1,2,5)] = [4, 5, 7]
print yet_another_dict
In [314]:
yet_another_dict[[1,2,7]] = [4, 5]
In [ ]: